package designpattern.observer.livedemo;

public class CalculatorTest {
    public static void main(String[] args) throws InterruptedException {
        Calculator calculator = new Calculator();

        // 添加观察者
        calculator.addObserver(new CalculationObserver() {
            @Override
            public void onProgressChanged(int step, int totalSteps) {
                System.out.println("进度: " + step + "/" + totalSteps);
            }

            @Override
            public void onCalculationComplete(float result) {
                System.out.println("计算完成，结果为: " + result);
            }
        });

        calculator.calc();
    }
}